<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>


  <div id="app">
    <button @click="buy(10)">快乐神仙水</button>
  </div>

  <script src="./vue2.6.12.js"></script>

  <script>
    // 需求: 创建一个按钮,实现调用buy购买方法,每次购买扣除vue对象data中余额

    var app = new Vue({
      el:'#app',
      data:{
        money : 100
      },
      methods:{
        buy(price){
          // 找到自己的money  扣钱
          this.money -= price
          alert("余额:" + this.money)
        }
      }
    })


  </script>
</body>
</html>